t=int(input())
while(t):
x=input()
l=len(x)
if(l==1):
print(x)
elif(l==2):
print(int(x[0])+int(x[1]))
else:
L=[]
m=18
M=0
for i in range(l-1):
m=min(m,int(x[i])+int(x[i+1]))
M=max(M,int(x[i])+int(x[i+1]))
if(int(x[i])+int(x[i+1])>=10):
L.append([i,int(x[i])+int(x[i+1])])
if(M<10):
print(str(int(x[0])+int(x[1]))+x[2:])
else:
i=L[-1][0]
print(x[:i]+str(int(x[i])+int(x[i+1]))+x[i+2:])
t-=1
#include<bits/stdc++.h>
#define ll long long
#define tt int ttt; cin >> ttt; while(ttt--)
#define vt vector<int>
#define nl "\n"
#define mtt for(auto i:mp)
#define mt for(auto &i:a) cin>>i;
#define vl vector<ll>
#define sor sort(v.begin(),v.end(),greater<>())
#define so sort(a,a+n,greater<>())
#define MARWA ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std ;
const ll N = 1000000007;
int main() {
MARWA
tt{
string s; cin>>s; bool f=0;
for (int i = s.size()-1; i >0 ; i--) {
int x=s[i]-'0',y=s[i-1]-'0';
if(x+y>9){
f=1; int b=x+y;
string m= to_string(b);
s[i-1]=m[0]; s[i]=m[1];
break;
}
}
if(f) cout<<s<<nl;
else{
int x=s[0]-'0',y=s[1]-'0';
int z=x+y; string v= to_string(z);
s.erase(0, 1);
s[0]=v[0];
cout<<s<<nl;
}
}
}
1822. Sign of the Product of an Array | 1464. Maximum Product of Two Elements in an Array |
1323. Maximum 69 Number | 832. Flipping an Image |
1295. Find Numbers with Even Number of Digits | 1704. Determine if String Halves Are Alike |
1732. Find the Highest Altitude | 709. To Lower Case |
1688. Count of Matches in Tournament | 1684. Count the Number of Consistent Strings |
1588. Sum of All Odd Length Subarrays | 1662. Check If Two String Arrays are Equivalent |
1832. Check if the Sentence Is Pangram | 1678. Goal Parser Interpretation |
1389. Create Target Array in the Given Order | 1313. Decompress Run-Length Encoded List |
1281. Subtract the Product and Sum of Digits of an Integer | 1342. Number of Steps to Reduce a Number to Zero |
1528. Shuffle String | 1365. How Many Numbers Are Smaller Than the Current Number |
771. Jewels and Stones | 1512. Number of Good Pairs |
672. Richest Customer Wealth | 1470. Shuffle the Array |
1431. Kids With the Greatest Number of Candies | 1480. Running Sum of 1d Array |
682. Baseball Game | 496. Next Greater Element I |
232. Implement Queue using Stacks | 844. Backspace String Compare |